/*
 * IBM Corporation.
 * Copyright (c) 2014 All Rights Reserved.
 */

package com.ibm.iisp.data.model;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import com.ibm.iisp.common.vo.RefBean;

/**
 * 类作用：
 * @author Johnny@cn.ibm.com
 * 使用说明：
 */
@Entity
@Table(name = "IISP_DATA_TAB")
@NamedQueries({
	@NamedQuery(name = DataTable.QUERY_GET_ALL, query = "select dt from DataTable dt where dt.isActive = true order by dt.groupName, dt.seq"),
	@NamedQuery(name = DataTable.QUERY_BY_NAME, query = "select dt from DataTable dt where dt.isActive = true and dt.name like :tableName order by dt.groupName, dt.seq")
})
@NamedNativeQueries({
	@NamedNativeQuery(name = DataTable.DATA_TABLE_DEF, query = "select column_name, comments from iisp_data_ie_table_cols where table_name = ?1")
})
public class DataTable extends RefBean {
	/**
	 * 
	 */
	private static final long serialVersionUID = 3868033058281802102L;
	
	public final static String QUERY_GET_ALL = "DataTable.QUERY_GET_ALL";
	public final static String QUERY_BY_NAME = "DataTable.QUERY_BY_NAME";
	public final static String DATA_TABLE_DEF = "DataTable.DATA_TABLE_DEF";
	private String description;
	private String groupCode;
	private String groupName;
	private Boolean isActive;
	private Integer seq;

	@OneToMany
	@JoinColumn(name = "TABLE_CODE", nullable = false)
	@OrderBy(value = "SEQ ASC")
	private List<DataTableColumn> columns;

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getGroupCode() {
		return groupCode;
	}

	public void setGroupCode(String groupCode) {
		this.groupCode = groupCode;
	}

	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	public List<DataTableColumn> getColumns() {
		return columns;
	}

	public void setColumns(List<DataTableColumn> columns) {
		this.columns = columns;
	}

	public Boolean getIsActive() {
		return isActive;
	}

	public void setIsActive(Boolean isActive) {
		this.isActive = isActive;
	}

	public Integer getSeq() {
		return seq;
	}

	public void setSeq(Integer seq) {
		this.seq = seq;
	}

}
